package com.bawei.module_goods.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.bawei.module_goods.R
import com.bawei.module_goods.databinding.ItemMallEventItemBinding
import com.bawei.module_goods.entity.EventsType

class MallEventAdapter : RecyclerView.Adapter<MallEventAdapter.EventViewHolder>() {

    private val eventList = mutableListOf<EventsType>()

    fun submitList(list: List<EventsType>) {
        eventList.clear()
        eventList.addAll(list)
        notifyDataSetChanged()
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): EventViewHolder {
        val binding = ItemMallEventItemBinding.inflate(LayoutInflater.from(parent.context), parent, false)
        return EventViewHolder(binding)
    }

    override fun getItemCount(): Int = eventList.size

    override fun onBindViewHolder(holder: EventViewHolder, position: Int) {
        holder.bind(eventList[position])
    }

    class EventViewHolder(private val binding: ItemMallEventItemBinding) : RecyclerView.ViewHolder(binding.root) {
        fun bind(event: EventsType) {
            binding.ivEventIcon.setImageResource(R.drawable.img_hot)
            binding.tvEventName.text = event.name
            binding.tvEventPrice.text = "享受热趣"
            // 可添加点击事件等
        }
    }
} 